package dwarffortress.io;

import java.io.InputStream;
import java.io.IOException;

public class CountingInputStream extends InputStream {
    int offset;
    InputStream stream;

    public CountingInputStream(InputStream stream) {
        this.stream = stream;
    }

    public int getOffset() {
        return offset;
    }

    public int read() throws IOException {
        int result = stream.read();
        if (result >= 0) {
            offset++;
        }
        return result;
    }

    public void close() throws IOException {
        super.close();
        stream.close();

    }
}
